package com.example.demo.config;

import com.example.demo.filter.ExecuteTimeFilter;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * @Author x c
 * @Email 378661553@qq.com
 * @Date Created in 2020/1/20 9:05
 */
@SpringBootConfiguration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean executeTimeFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new ExecuteTimeFilter());
        registration.addUrlPatterns("/*");
        // order值越小越优先
        registration.setOrder(0);
        return registration;
    }

}
